//
//  HMHomeBottomView.swift
//  HMSlender
//
//  Created by 赵少朋赵少朋 on 2017/2/5.
//  Copyright © 2017年 ITheima. All rights reserved.
//

import UIKit

class HMHomeBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.white
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() -> Void {
        
        let commentBtn = createButton(title: "评论", imgName: "timeline_icon_comment")
        let transmitBtn = createButton(title: "转发", imgName: "timeline_icon_retweet")
        let praiseBtn = createButton(title: "赞", imgName: "timeline_icon_unlike")
        //评论 转发 赞 btn
        addSubview(transmitBtn)
        addSubview(commentBtn)
        addSubview(praiseBtn)
        
        transmitBtn.snp_makeConstraints { (make) in
            make.top.left.bottom.equalTo(self)
            make.width.equalTo(SCREENWIDTH/3)
        }
        commentBtn.snp_makeConstraints { (make) in
            make.top.bottom.equalTo(self)
            make.left.equalTo(transmitBtn.snp_right)
            make.width.equalTo(transmitBtn)
        }
        praiseBtn.snp_makeConstraints { (make) in
            make.top.right.bottom.equalTo(self)
            make.width.equalTo(transmitBtn)
        }
    }
    
}

extension HMHomeBottomView {

    func createButton(title: String, imgName:String) -> UIButton {
        
        let button = UIButton()
        button.setTitle(title, for: UIControlState.normal)
        button.setImage(UIImage(named:imgName), for: UIControlState.normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: midTextFont)
        button.setTitleColor(UIColor.darkGray, for: UIControlState.normal)
        return button
    }
    
}
